package cms.common;

/**
 * 功能: 业务响应信息封装
 * Author: yuhui
 * Date: 2021/4/8 15:45
 */
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;

    /**
    * 功能描述: 业务处理成功响应，无数据
    * @Author: yuhui  2021/4/8 15:48
    */
    public Result() {
        this.code = CodeMsg.SUCCESS.code;
        this.msg = CodeMsg.SUCCESS.msg;
    }

    /**
    * 功能描述: 响应成功，且有数据返回
    * @Author: yuhui  2021/4/8 15:49
    */
    public Result(T data) {
        this();
        this.data = data;
    }

    /**
    * 功能描述: 异常情况的响应结果
    * @Author: yuhui  2021/4/8 15:51
    */
    public Result(CodeMsg cm){
        this.code = cm.code;
        this.msg = cm.msg;
    }

    /**
    * 功能描述: 自定义响应结果
    * @Author: yuhui  2021/4/8 15:52
    */
    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
